package com.mes.basicdata.service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bstek.dorado.annotation.DataProvider;
import com.mes.basicdata.dao.iface.IDeviceClassDao;
import com.mes.basicdata.domain.DeviceClass;
import com.mes.common.service.BasicService;
@Service
public class DeviceClassService extends BasicService<DeviceClass>{
	
	@Autowired
	private IDeviceClassDao deviceClassDao;
	
	@DataProvider
	public Collection<DeviceClass> getParent(){
		String hql = "from DeviceClass where parentDeviceClassUid!=null";
		return deviceClassDao.find(hql);
		
	}
	
	@DataProvider
	public List<DeviceClass> getChildDeviceClass(String parentDeviceClassId){
		List<DeviceClass> list = new ArrayList<>();
		
		try {
			list = deviceClassDao.findByProperty("parentDeviceClassUid", parentDeviceClassId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return list;
	}
}
